package com.example.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.admin.service.UserService;
import com.usian.model.admin.pojos.AdUser;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class UserController {

    @Autowired
    private UserService userService;
    @PostMapping("add_user")
    public ResponseResult addUser(){
        int a = 1/0;
        AdUser adUser = new AdUser();
        adUser.setName("zhaoyu");
        adUser.setNickname("zy");
        adUser.setCreatedTime(new Date());
        userService.addUser(adUser);


      return ResponseResult.okResult(200,"") ;


    }

    @GetMapping("list")
    public ResponseResult getUser(){
        return ResponseResult.okResult(userService.getUserList());
    }
    @GetMapping("list_page")
    public ResponseResult getUserPage(){

        return PageResponseResult.okResult(userService.getUserList2());
    }

}
